<template>
<a :href="detailUrl">
  <div class="book-card">
    <div class="thumb" @click.stop='preview'>
      <img :src="book.image"
        mode="aspectFit"
        class="image">
    </div>
    <div class="detail">
      <div class="row text-primary">
        <div class="left">
          {{book.title}}
        </div>
        <div class="right">
          {{book.rate}}<Rate :value='book.rate'></Rate>
        </div>
      </div>
      <div class="row">
        <div class="left">
          {{book.author}}
        </div>
        <div class="right text-primary">
          浏览量：{{book.count}}
        </div>
      </div>
      <div class="row">
        <div class="left">
          {{book.publisher}}
        </div>
        <div class="right">
          {{book.user_info.nickName}}
        </div>
      </div>
    </div>
  </div>
  </a>
</template>

<script>
import Rate from './Rate'
export default {
  props: ['book'],
  components: {
    Rate
  },
  computed: {
    detailUrl () {
      return '/pages/detail/main?id=' + this.book.id
    }
  },
  methods: {
    preview () {
      wx.previewImage({
        current: this.book.image,
        urls: [this.book.image]
      })
    }
  }
}
</script>

<style lang='scss' scoped>
.book-card {
  padding: 5px;
  overflow: hidden;
  margin-top: 5px;
  margin-bottom: 5px;
  display: flex;
  font-size: 14px;
  .thumb {
    width: 90px;
    height: 90px;
    flex: 0 90px;
    img {
      max-width: 100%;
      max-height: 100%;
    }
  }
  .detail{
    flex: 1;
    margin-left: 10px;
    .row{
      display: flex;
      line-height: 20px;
      margin-bottom: 3px; 
      justify-content:space-between
    }
    .left {
      flex: 0 160px;
      word-break:break-all
    }
  }
}
</style>
